package com.careercup.question.id14946517;

import java.util.LinkedList;
import java.util.Queue;

public class Solution {
	private static class Node {
		Node left, right;
		int value;
		public Node(int value) {
			this.value = value;
		}
		public void bfs() {
			Queue<Node> l = new LinkedList<Node>();
			l.add(this);
			while(!l.isEmpty()) {
				Node cn = l.remove();
				System.out.println(cn.value);
				if(cn.left != null)
					l.add(cn.left);
				if(cn.right != null)
					l.add(cn.right);
			}
		}
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		 Node n1 = new Node(1), n2 = new Node(2);
		 Node n3 = new Node(3), n4 = new Node(4);
		 Node n5 = new Node(5), n6 = new Node(6);
		 Node n7 = new Node(7), n8 = new Node(8);
		 Node n9 = new Node(9), n10 = new Node(10);
		 Node n11 = new Node(11), n12 = new Node(12);
		 Node n13 = new Node(13), n14 = new Node(14);
		 Node n15 = new Node(15);
		 n1.left = n2;
		 n1.right = n3;
		 n2.left = n4;
		 n2.right = n5;
		 n3.left = n6;
		 n3.right = n7;
		 n4.left = n8;
		 n4.right = n9;
		 n5.left = n10;
		 n5.right = n11;
		 n6.left = n12;
		 n6.right = n13;
		 n7.left = n14;
		 n7.right = n15;
		 n1.bfs();
	}
}
